<!DOCTYPE html>
<html class="x-admin-sm">

	<head>
		<meta charset="UTF-8">
		<title>欢迎页面-X-admin2.2</title>
		<!--<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
		<link rel="stylesheet" href="./css/font.css">
		<link rel="stylesheet" href="./css/xadmin.css">
		<link rel="stylesheet" type="text/css" href="lib/layui/css/layui.css" />
		<script src="lib/layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript" src="./js/xadmin.js"></script>
		<script src="js/global.js" type="text/javascript" charset="utf-8"></script>-->
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <meta http-equiv="Cache-Control" content="no-siteapp" />
        <link rel="stylesheet" href="css/font.css">
        <link rel="stylesheet" href="css/xadmin.css">
         <link rel="stylesheet" href="css/theme3177.min.css" />
        <!-- <link rel="stylesheet" href="./css/theme5.css"> -->
        <script src="lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="js/xadmin.js"></script>
        <script type="text/javascript" src="js/global.js" ></script>
		<!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
	</head>

	<body>
		<div class="layui-fluid">
			<div class="">
				<form class="layui-form" id="updateMmForm" method="post" lay-filter="updateMmForm" style="margin-top: 20px;">
					
					<div class="layui-form-item">
						<label class="layui-form-label">原密码</label>
						<div class="layui-input-block">
							<input type="text" name="Id" placeholder="请输入登录名" id="uid" style="display: none;" class="layui-input" autocomplete="off" autofocus/>
							<input type="password" name="Password" placeholder="请输入旧密码" id="jmm" class="layui-input" autocomplete="off" autofocus />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">新密码</label>
						<div class="layui-input-block">
							<input type="password" name="newPassword" placeholder="请输入新密码" id="xmm" class="layui-input" autocomplete="off" autofocus />
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">再次确认密码</label>
						<div class="layui-input-block">
							<input type="password" name="newPassword1" placeholder="请再次确认密码" id="xmm1" class="layui-input" autocomplete="off" autofocus />
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-input-block" align="center" style="margin-right: 50px;">
							<input id="upMm" class="layui-button layui-btn-sm" type="button" value="确认" />
						</div>
					</div>
				</form>
			</div>
		</div>
		<script>
			layui.use(['form', 'layer'],
				function() {
					$ = layui.jquery;
					var form = layui.form,
						layer = layui.layer;

					/*修改个人密码*/
					$("#upMm").click(function() {
						var uid = document.getElementById("uid").value;//用户id
						var jmm = document.getElementById("jmm").value;//旧密码
						var xmm = document.getElementById("xmm").value;//新密码
						var xmm1 = document.getElementById("xmm1").value;//再次确认密码
						if(xmm != '') {
							if(xmm != jmm) {
								if(xmm.length > 5) {
									if(xmm1 != '') {
										if(xmm == xmm1) {
											$.post("http://localhost:8080/updateMm", {
												'Id': globalData.getCurUid(),
												"Password": jmm,
												"newPassword": xmm,
												"token": globalData.getCurToken()
											}, function(res) {
												if(res.success) {
													layer.msg("修改成功,3秒后将会重新登录!", {
														icon: 1
													});
													
													globalData.setUserInfo(null,null,null,null);
													/*top.location.href = "login.html";*/
													setTimeout('top.location.href = "login.html"', 3000);
												} else {
													layer.msg("旧密码错误，请核实密码后再进行修改", {
														icon: 7
													});
												}
											}, "json");
										} else {
											layer.msg("请确定您两次输入的密码是否一致", {
												icon: 0
											})
										}
									} else {
										layer.msg("请再次输入新密码", {
											icon: 0
										});
									}
								} else {
									layer.msg("密码长度必须大于5位", {
										icon: 0
									});
								}
							} else {
								layer.msg("密码没有改动，请重新设置密码", {
									icon: 0
								});
							}
						} else {
							layer.msg("请输入新密码", {
								icon: 0
							});
						}
					})

				});
		</script>

	</body>

</html>